<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../vue.js"></script>
</head>

<body>
  <div id="app">
    <button @click="addAttr">新增sex属性</button>
    <button @click="deleteAttr">删除name属性</button>
    <button @click="person.age++">年龄自增</button>
    <p>姓名是{{person.name}}</p>
    <p>年龄为{{person.age}}</p>
    <p>性别是{{person.sex}}</p>
  </div>
  <script>
    Vue.config.productionTip = false;

    const vm = new Vue({
      el: "#app",
      data() {
        return {
          person: {
            name: "xiaowang",
            age: 26,
          }
        }
      },
      methods: {
        deleteAttr() {
          // this.$delete(this.person, "name")
          Vue.delete(this.person,"name")
        },
        addAttr() {
          // this.$set(this.person, "sex", "男")
          Vue.set(this.person,"sex","男")
        }
      }
    })
  </script>
</body>

</html>